<template>
	 <div id="entry"></div>
</template>

<script>
import Vue from 'vue'
import VueResource from 'vue-resource'
Vue.use(VueResource)

function GetRequest(strName) {
    var strHref = window.location.href
    var intPos = strHref.indexOf("?");
    var strRight = strHref.substr(intPos + 1);
    var arrTmp = strRight.split("&");
    for (var i = 0; i < arrTmp.length; i++) {
      var arrTemp = arrTmp[i].split("=")
      if (arrTemp[0].toUpperCase() == strName.toUpperCase()) {
        return arrTemp[1]
      }
    }
    return '';
  }

export default {
	components: {
	},
	data () {
	  	return{
            url:{}
	  	}
	},
	methods:{  	
	},
    mounted(){
        var appid = 'wxe269be5d7e65716d'
        var redirect_uri = 'http://www.nowdone.com.cn/c'
        var eid = GetRequest("eid")
        if(eid){
            this.$http.get('/oauth/v1/wechat/verifyeid/'+eid)
            .then((res)=>{
                console.log(res.data)
                if(res.data.code == '1'){
                    localStorage.setItem("eid",eid)
					window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + appid + '&redirect_uri=' + redirect_uri + '&response_type=code&scope=snsapi_userinfo&state=666#wechat_redirect'
                }else{
                    console.error('error')
                    this.$router.push('/error')
                }
            },(err)=>{
                console.error('error')
            })
        }else{
            this.$router.push('/error')
        }
    }
}
</script>

<style lang="less"></style>
